package com.cskaoyan.day24.reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Scanner;

public class TestStudent {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Scanner sc = new Scanner(System.in);
        Class<?> stuClass = Class.forName("com.cskaoyan.day24.reflect.Student");
        String s = sc.nextLine();
        String[] split = s.split("：");
        String name = split[0];
        int age = Integer.parseInt(split[1]);
        int score = Integer.parseInt(split[2]);
        Constructor<?> declaredConstructor = stuClass.getDeclaredConstructor(String.class, int.class, int.class);
        Student stu = (Student)declaredConstructor.newInstance(name, age, score);
        Method toString = stuClass.getMethod("toString");
        System.out.println(toString.invoke(stu));


    }
}
